Post

Replies

Boosts

Views

Activity

Mac Catalyst: UISplitViewControllerColumnSecondary doesn't get key focus when the Tab Key is Pressed in a Triple UISplitViewController.
My UISplitViewController is configured like this: A list (collection view) is used in the primary view controller (sidebar style). When a selection is made in the primary view controller a table view displays data in the supplementary column. When a selection is made in the supplementary view controller, a view controller with scrollable content is shown in the secondary view controller. This is like the Mail app on Mac. So when I run the app I hit the tab key once and the list (collection view) in the primary column gets focus. I can navigate the list with the keyboard. This works as expected. So now with a selection in the list, a table view is showing in the supplementary column. I hit the tab key again and the table view gets focus. This works as expected as I can navigate the table view from the keyboard with the arrow keys. Now with a selection made in the table view, the scrollable view controller is showing in the secondary view controller column. I hit the tab key again and focus goes back to the list in the primary column. This is not the expected behavior. I'd expect hitting tab would move focus to the scroll view in the secondary column instead of jumping back to the primary column (as I should be able to scroll the scroll view in the secondary column with the up and down arrow keys). The user is then required to click on the secondary view controller in order to scroll it with the arrow keys. This breaks full keyboard navigation. The behavior I'm after is actually the default behavior in the Mail app but I can't figure out how to get it to work in Mac Catalyst?
3
0
739
Nov ’22
Update title of NSMenuItem in Menu Bar on Mac Catalyst Based on Current Context?
I'm using UIMenuBuilder API to add a menu item to the menu bar on Mac Catalyst (adding a UIKeyCommand object). So depending on the current selection the title of the menu item should change. As an example in Finder if a single file is selected and you go to the "Edit" menu in the menu bar there is an item that says "Copy Filename" Now select two files in Finder and go to Edit menu in the menu bar and now it says "Copy 2 Items" Updating a NSMenuItem in Appkit is pretty easy. I figured I'd be able to do this in -canPerformAction:withSender: but the system doesn't pass my UIKeyCommand as the sender but instead an instance of a private class _UIMenuBarItem. I assume there must be a way to dynamically update the title of a menu bar item in a Catalyst app?
1
0
851
Nov ’22
UITableView Doesn't Properly Update Focus When Extending Selection by Holding the Shift Key+Clicking on Mac Catalyst
My table view supports multiple selection. When holding down the shift key and clicking to extend the selection on Mac focus doesn't move to the clicked row. This isn't how macOS apps normally behave. I tried working around the problem by catching the last selected index path and forcing a focus update: -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { self.lastSelectedIndexPath = indexPath; } -(void)tableView:(UITableView*)tableView didDeselectRowAtIndexPath:(NSIndexPath*)indexPath {     if ([indexPath isEqual:self.lastSelectedIndexPath])     {         self.lastSelectedIndexPath = nil;     } } -(void)tableViewDidEndMultipleSelectionInteraction:(UITableView *)tableView {   [tableView setNeedsFocusUpdate];     [tableView updateFocusIfNeeded]; } -(NSIndexPath*)indexPathForPreferredFocusedViewInTableView:(UITableView *)tableView { return self.lastSelectedIndexPath; } But that didn't work. UITableview never calls -indexPathForPreferredFocusedViewInTableView: after my -setNeedsFocusUpdate / -updateFocusIfNeeded calls. I tried subclassing UITableView and overriding -preferredFocusEnvironments but that isn't called. Focus system just ignores updating for shift click. Anyone know of a workaround?
1
0
570
Oct ’22
Determine selected text color to use in Mac Catalyst for UITableView Cells When Row is Selected But Table View Doesn't Have Active Focus?
So when a row is selected in UITableView and the table view / cells within it have focus, and the window is active.... the rows are selected with the system Accent color (in my case blue). I have a view inside the table view cell that does custom drawing. When the cell is selected I draw text white (when unselected I draw the text using UIColor.labelColor). So when the window is not active but the table view row is selected, the selected background color changes to light gray. In this case I draw the text black (because it looks better against the light gray selection color on an inactive window). However when the row is selected but another view in the window has focus (say the sidebar) the selected row turns back to the light gray color. In this case my text is incorrectly drawing white instead of black on the light gray background. How do I check for this state from UIKit? In AppKit I think I'd be using: NSColor.unemphasizedSelectedTextColor https://developer.apple.com/documentation/appkit/nscolor/2998834-unemphasizedselectedtextcolor?language=objc I have to update text color manually because I'm doing custom drawing in these table view cells (I have a view that overrides drawRect:) I can't just use the dynamic colors like UIColor.labelColor. I have to set the colors on state change manually and call setNeedsDisplay on my view. How do I check for the unemphasized state? I did inspect whether or not my table view cell is in the active focusItem's environment, and if it is not I assume the light gray selected color is being used. This worked most of the time but there still seems to be some states where the unemphasized selection color (light gray)is being used on selected cells when the the table view cell is in the active focus environment and my text incorrectly draws white.
1
1
1.4k
Oct ’22
Crash: Focus item <UITableViewCell> does not provide a parentFocusEnvironment.
I'm on Mac Catalyst. I have a UISearchController and I keep getting this crash after I clear the search bar, adjust the search scope segmented control if one of the UITableViewCells is focused (via arrow key press) before Focus item does not provide a parentFocusEnvironment. I can workaround the problem by overriding -parentFocusEnvironment, holding the parent UITableView in a property and returning it: -(id<UIFocusEnvironment>)parentFocusEnvironment { id<UIFocusEnvironment>theFocus = [super parentFocusEnvironment]; if (theFocus == nil) { return self.cachedParentFocus; } else { self.cachedParentFocus = theFocus } return theFocus; } The problem with this is it is likely to create a retain cycle (I did try a weak reference but that can cause the following crasher on deallocation (the focus environment continues to call this method on the table view cell even when its outside of a UIWindow): “Cannot form weak reference to instance (0x13799a000) of class UITableView. It is possible that this object was over-released, or is in the process of deallocation.” Anyone run into this and know of a potential workaround?
1
0
839
Oct ’22
Disable vibrancy on titlebar/toolbar area of window on Mac Catalyst?
I can't seem to get rid of the "vibrancy" effect on the titlebar/toolbar area of the window on Mac Catalyst. I have a triple Split View controller. The primary vc style is sidebar in the split vc.. And that has the blur/visual effect and that's all well and good. But the title bar area on the supplementary column has the blur effect too and it looks kind of terrible (the navigation bar in the supplementary view controller has all of its navigationBar appearances configured with opaque content:   UINavigationBarAppearance *opaqueAppearance = [[UINavigationBarAppearance alloc]init];     [opaqueAppearance configureWithOpaqueBackground];     opaqueAppearance.backgroundEffect = nil;     opaqueAppearance.backgroundColor = [UIColor myColor]; //set to all appearances But I still get the blur effect on the navigation bar, which presumably is being mapped to NSToolbar. Is it possible to disable this blur effect for the column? It really doesn't look good in my app.
0
0
539
Oct ’22
UINavigationController inside UISplitViewController's UISplitViewControllerColumnSupplementary Doesn't Appear on Mac Catalyst
Working on a Mac Catalyst app. I have a UInavigationController. On iOS this is full screen but on Mac Catalyst I'm using it inside a UISplitViewController in the supplementary column. This view controller's root view controller has a navigationItem which configures a UISearchController. The search bar is nowhere to be found unless I set it to UINavigationItemSearchBarPlacementStacked. So is UINavigationItemSearchBarPlacementInline not supported for the supplementary column of a UISplitViewController? If that's the case I'm fine with that actually but there's got to be a way to make UINavigationItemSearchBarPlacementStacked look a little better on Mac? The search bar border is barely visible on a white background.
1
0
1k
Oct ’22
UICollectionView List Style on Mac Catalyst: Prevent the Collection View From Changing the Selection when the Selected Row's Parent is Collapsed?
I'm using UICollectionView with a list style on Mac (looks like NSOutlineView in a sidebar). I have expandable rows. So this is the behavior I'm after: -If the user has a row selected, but decides to collapse the selected row's parent, I want to maintain the current selection. Instead this is what happens by default: -If a row selected and I collapse the parent the collection, the collection view automatically selects another row (in my case the first row at index path 0-0). Just because the user collapses the parent doesn't mean the selection should change. For instance in Xcode's Navigator I can have a file selected in a Group and collapse the group without modifying the current selection.
2
0
522
Oct ’22
Is it possible to use Settings.bundle just for Mac Catalyst, and not for the iOS version of the app?
I was wondering if it was possible to use a Settings.bundle just for the Mac Catalyst version of the app? On the iOS version I handle my preferences in app as it is easier to sync with iCloud key value storage, plus doing it in-app has the added convenience of not making the user navigate to the Settings app to manage preferences. On Mac Catalyst however using a Settings.bundle would be nice because I'd get UI for free and the user doesn't have to navigate to a different app to manage preferences. Also I have a few preferences that only apply to the iOS version of the app, and some that only apply to the Mac version of the app (preferences that don't apply to the platform the app is running on should be excluded from the UI). So is there a way to specify a Settings.bundle just for Mac Catalyst? If not, is there a way to specify that a particular preference is "Mac Only" in the plist files inside the Settings bundle?
1
0
932
Oct ’22
Unable to get CloudKit sync Notifications on Mac Catalyst Build -application:didFailToRegisterForRemoteNotificationsWithError: is being called
Working on a Mac Catalyst version of one of my apps. I noticed making changes on my iPhone (debug environment) aren't being pushed to my Mac (also in debug environment). Then when I quit and relaunch the app and manually force an iCloud sync at launch I get all the changes. At app launch I see the following method is being called on my AppDelegate after I attempt to register remote notifications: -application:didFailToRegisterForRemoteNotificationsWithError: with the error: Notifications are not allowed for this application" UserInfo={NSLocalizedDescription=Notifications are not allowed for this application}. Anyone experience this and have a solution? Under "Signing and Capabilities" I see an entry for Push Notifications for iOS and macOS.
1
0
860
Oct ’22
Mac Catalyst When to Handle Setting Min/Max Size for UISplitViewController columns? Window Resize Event?
Trying to use UISplitViewController. Since this app can be run on many different monitor sizes I want to allow the splits to be resized reasonably. There is this API: //Allow setting the primary column width with point values. This is especially useful in Catalyst where the window may be resized more often. // If set to non-Automatic, takes precedence over preferredPrimaryColumnWidthFraction. @property(nonatomic, assign) CGFloat preferredPrimaryColumnWidth API_AVAILABLE(ios(14.0)); // default: UISplitViewControllerAutomaticDimension > > @property(nonatomic, assign) CGFloat minimumSupplementaryColumnWidth API_AVAILABLE(ios(14.0)); @property(nonatomic, assign) CGFloat maximumSupplementaryColumnWidth API_AVAILABLE(ios(14.0)); // An animatable property that can be used to adjust the minimum absolute width of the primary view controller in the split view controller. @property(nonatomic, assign) CGFloat minimumPrimaryColumnWidth API_AVAILABLE(ios(8.0)); // default: UISplitViewControllerAutomaticDimension // An animatable property that can be used to adjust the maximum absolute width of the primary view controller in the split view controller. @property(nonatomic, assign) CGFloat maximumPrimaryColumnWidth API_AVAILABLE(ios(8.0)); // default: At what point in time should I be changing the preferredPrimaryColumnWidth, the min/and max width values? What event? If I was in Appkit I could maybe use something like NSWindowDidResizeNotification, then compute min/max sizes for each column based off the current window size (but I think NSSplitView gives the delegate an opportunity to control constraining column sizes if I remember correctly so I don't think that it would necessary to listen for a window resize event). I find the default sizes set by UISplitViewController to be insufficient (I want to allow users to size columns wider). Ideally this would be easier if there was minimumPrimaryColumnFraction and maxPrimaryColumnFraction. Then I just set the min/max fractions once to reasonable values and not worry about changing them on window resize. But since we can only set min/max with a hardcoded point size it seems more complicated?
0
1
411
Oct ’22
UISplitViewController on Mac Catalyst Collapse the Primary (Sidebar) View Controller by Dragging the Split macOS Style?
So experimenting with UISplitViewController on Mac Catalyst. I have a triple split. The primary view controller is a sidebar. I have the default sidebar button showing in the toolbar and that collapsed/expands the sidebar fine. But when I drag to try to collapse the split (as is typical on macOS) the sidebar doesn't collapse. It clamps to the min. size. Is there anyway to enable this? I tried passing 0 to -setMinimumPrimaryColumnWidth: but that didn't work.
3
0
796
Oct ’22
Window's title bar separator draws way out of place on Mac Catalyst, not even close to title bar location
So I built my app with Mac Catalyst. I see this little line appear and disappear periodically in the window. Then all of a sudden it disappears when the window's activation state changes sometimes. It looks like a weird little glitch. Turns out this is the title bar's separator which is UITitlebarSeparatorStyleAutomatic (I believe the system hides/shows the separator in this mode based on current window states. I change the separator style to shadow and sure enough it draws like a shadow and never disappears. It's not even close to where the separator is supposed to be (nowhere near the title bar). The only workaround I have is to use UITitlebarSeparatorStyleNone which I'll do if I have to but was wondering if someone else has run into this and has a better workaround.
4
1
821
Oct ’22
if (@available(macCatalyst 15.0,*)) vs if (@available(iOS 15.0, *))
Experimenting with Mac Catalyst a bit. I see sometimes the compiler warns me about an API and suggests this fix:   if (@available(macCatalyst 15.0,*)) { /// Use API for this version of catalyst.... } And when I switch back to run on an iOS device the warning comes back and this time I get the suggestion: if (@available(iOS 15.0, *)) { //iOS 15 } If I just use the @available iOS 15 check and remove the macCatalyst check the compiler stops warning me when I try building on my Mac and on iOS, but the same isn't true the other way around (if I have code inside the macCatalyst version check, switching to build for an iOS device still warns me). I was expecting that code inside the if @available(macCatalyst 15,*) statement would only run on Mac catalyst if the version of macOS supports the API, but would not run on iOS at all (even if the API is available there too) but I still get compiler warnings on iOS and a suggestion for an extra if (@available(iOS 15.0, *)) which produces the following:  if (@available(macCatalyst 15.0,*))     {         if (@available(iOS 15.0, *))         { //do something iOS 15 and later...and macCatalyst 15 and later. } } What do I make of the macCatalyst availability check? It comes up in code completion but just using the iOS check seems like the correct way (it silences compiler warnings but I haven't tested on an older version of macOS to see if using any of this API would produce a crash). I conclude that if (@available(iOS 15.0, )) should be used pretty much always instead of if (@available(macCatalyst 15.0,)) and if I need code only for Mac Catalyst I should check the TARGET_OS_MACCATALYST macro instead:  #if TARGET_OS_MACCATALYST #else //iOS only #endif Is that correct?
1
0
986
Oct ’22